from tkinter import *
from tkinter.colorchooser import askcolor


def set_bg_color():
    """设置背景颜色"""
    (triple, hexstr) = askcolor()
    if hexstr:
        print("返回的颜色值是：", hexstr)
        push.config(bg=hexstr)


root = Tk()
push = Button(root, text='设置背景颜色', command=set_bg_color)
push.config(height=3, font=('times', 20, 'bold'))
push.pack(expand=YES, fill=BOTH)
root.mainloop()
